home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
130 MIDI Tool Box
/
130 MIDI Tool Box.iso
/
peek_pas
/
peek.pas
next >
Wrap
Pascal/Delphi Source File
|
1987-08-18
|
3KB
|
94 lines
PROGRAM PEEK; {tlb}
TYPE
STR1 = STRING[1];
STR2 = STRING[2];
VAR
J, MIDIDATA: BYTE;
CONST
DATAPORT = $330; { THESE ARE PORT ADDRESSES FOR THE }
STATPORT = $331; { IBM VERSION OF THE MPU-401. }
DRS = $80; { THEY MUST BE CHANGED FOR OTHER }
DRR = $40; { MACHINES. }
ACK = $FE;
PROCEDURE PUTDATA (MIDIDATA:BYTE); { PUTS ONE BYTE TO MPU. }
BEGIN
J := 0;
REPEAT { REPEAT UNTIL DATA READY TO SEND }
J := PORT [STATPORT]; { HAS CORRECT VALUE; THEN SEND }
UNTIL (J AND DRR) = 0; { MIDI DATA TO DATAPORT. }
PORT [DATAPORT] := MIDIDATA;
END;
PROCEDURE GETDATA (VAR MIDIDATA:BYTE); { GETS ONE BYTE FROM MPU. }
VAR
J:BYTE;
BEGIN
J := 0;
REPEAT { LOOP UNTIL DATA READY TO RECEIVE }
J := PORT [STATPORT]; { HAS CORRECT VALUE; THEN GET MIDI }
UNTIL (J AND DRS) = 0; { DATA FROM DATAPORT. }
MIDIDATA := PORT [DATAPORT];
END;
PROCEDURE PUTCMD (CMD:BYTE); { SENDS COMMAND TO MPU. }
BEGIN
J := 0;
REPEAT { LOOP UNTIL DATA READY TO RECEIVE }
J := PORT [STATPORT]; { HAS CORRECT VALUE; THEN SEND }
UNTIL (J AND DRR) = 0; { COMMAND TO MPU. }
PORT [STATPORT] := CMD;
REPEAT { WAIT IN LOOP UNTIL MPU SENDS BYTE }
GETDATA(J); { TO ACKNOWLEDGE RECEIPT OF COMMAND. }
UNTIL J = ACK;
END;
FUNCTION HEX(B:BYTE):STR2;
CONST
H : ARRAY [0..15] OF CHAR = '0123456789ABCDEF';
BEGIN
HEX := H [B SHR 4] + H [B AND 15];
END;
{ M A I N P R O G R A M }
BEGIN
PUTCMD ($3F); { PUT MPU INTO UART MODE. }
WRITELN ('UART ON...');
REPEAT { BEGIN LOOP. }
GETDATA (MIDIDATA); { GET MIDI DATA FROM MPU. }
IF (MIDIDATA <> $FE) THEN { IF IT'S NOT AN ACTIVE-SENSING BYTE...}
WRITE (HEX (MIDIDATA), ' '); { ...THEN WRITE TO THE SCREEN.}
UNTIL KEYPRESSED = TRUE; { REPEAT... }
PUTDATA ($FF); { RESET MPU. }
END.
---|
| | MG